package come.tool.Fighting;

import java.awt.Color;
import java.awt.Graphics;

import com.tool.tcp.GetTcpPath;
import com.tool.tcp.Sprite;
import com.tool.tcp.SpriteFactory;
import com.tool.tcpimg.UIUtils;

public class DataDisplay {
    static int TILIU=1300;
    //tcp路径
    private String tcp;
	private Color tsc;
	private String ts;
	private String hpbig;
	private String hpsmall;
	private Color hpc;
	private String mpbig;
	private String mpsmall;
	private Color mpc;
	private long time;
	public DataDisplay() {
		// TODO Auto-generated constructor stub
	}
	//致命 怨气 吸收 怒气 狂暴  4倍 3倍
	//致命 怨气 吸收 怒气 狂暴  4倍 3倍
	public DataDisplay(String ts, int hp, int mp) {
		super();
		if (ts!=null) {
			if ("致命".equals(ts)) {
				tcp=GetTcpPath.getMouseTcp("ztzm");
			}else if ("怨气".equals(ts)) {
				tcp=GetTcpPath.getMouseTcp("ztyq");
			}else if ("吸收".equals(ts)) {
				tcp=GetTcpPath.getMouseTcp("ztxs");
			}else if (ts.startsWith("吸收")) {
				tcp=GetTcpPath.getMouseTcp("ztxs");
				this.ts = "吸收";
				
				String str = ts.substring(2).trim();
				hpc = new Color(8,170,148);
				if(str.length()>=6){
					hpbig =   str.substring(0, str.length()-4);
					hpsmall = str.substring(str.length()-4,str.length());
				}else{
					hpsmall = str;
				}
			}else if ("怒气".equals(ts)) {
				tcp=GetTcpPath.getMouseTcp("ztnq");
			}else if ("至圣".equals(ts)) {
				tcp=GetTcpPath.getMouseTcp("zssh");
			}else if ("狂暴".equals(ts)) {
				tcp=GetTcpPath.getMouseTcp("ztkb");
			}else if ("4倍".equals(ts)) {
				tcp=GetTcpPath.getMouseTcp("zt4b");
			}else if ("3倍".equals(ts)) {
				tcp=GetTcpPath.getMouseTcp("zt3b");
			}else {
				this.ts = ts;
				tsc=Color.YELLOW;
			}
		}
		if (hp!=0) {
			String values = null;
			if (hp>0) {
				values="+"+hp;
				hpc=Color.GREEN;
			}else {
				values=hp+"";
				hpc=UIUtils.COLOR_HURTR1;
				if (ts!=null && "至圣".equals(ts)) {
					hpc = new Color(249, 255, 240);
				}
			}
			if(values.length()>=6){
				hpbig =   values.substring(0, values.length()-4);
				hpsmall = values.substring(values.length()-4,values.length());
			}else{
				hpsmall = values;
			}
		}
		if (mp!=0) {
			String values = null;
			if (hp>0) {
				values="+"+mp;
			}else {
				values=mp+"";
			}
			mpc=new Color(30, 144, 255);
			if(values.length()>=6){
				mpbig =   values.substring(0, values.length()-4);
				mpsmall = values.substring(values.length()-4,values.length());
			}else{
				mpsmall = values;
			}
		}
		this.time=0;
	}
	public String ZM="致命";
	//狂暴黄色   致命蓝色 血量红色  蓝量蓝色
	public boolean draw(Graphics g,int x,int y,int camp,long dietime){
		time+=dietime;
		if (time>TILIU) {
            return true;
        }
		int sum=(int) (time/15);
		y-=sum;
		if (tsc!=null) {
			int row = x-ts.length()*16-5;
			//画文字
			g.setFont(UIUtils.nameFont);
			g.setColor(UIUtils.COLOR_HURTB2);
			g.drawString(ts, row-1, y);
			g.drawString(ts, row+1, y);
			g.drawString(ts, row, y-1);
			g.drawString(ts, row, y+1);
			g.setColor(tsc);
			g.drawString(ts, row, y);	
		}
		if (tcp!=null) {
			Sprite sprite=SpriteFactory.Prepare(tcp);
			if (sprite!=null) {
				sprite.updateToTime(0, 0);
				sprite.draw(g, x-40, y-15);
			}
		}
		if (hpc!=null) {
			int row1 = x;
			if (hpbig!=null) {
				g.setFont(UIUtils.TEXT_FONT22);
				g.setColor(Color.BLACK);
				g.drawString(hpbig, x-1, y);
				g.drawString(hpbig, x+1, y);
				g.drawString(hpbig, x, y-1);
				g.drawString(hpbig, x, y+1);
				g.setColor(hpc);
				g.drawString(hpbig, x, y);
				row1+=hpbig.length()*10;
			}
			g.setFont(UIUtils.TEXT_HURT2);
			g.setColor(Color.BLACK);
			g.drawString(hpsmall, row1-1, y);
			g.drawString(hpsmall, row1+1, y);
			g.drawString(hpsmall, row1, y-1);
			g.drawString(hpsmall, row1, y+1);
			g.setColor(hpc);
			g.drawString(hpsmall, row1, y);
		}
		y-=15;
        if (mpc!=null&&camp==FightingMixDeal.camp) {
        	int row1 = x;
			if (mpbig!=null) {
				g.setFont(UIUtils.TEXT_FONT22);
				g.setColor(Color.BLACK);
				g.drawString(mpbig, x-1, y);
				g.drawString(mpbig, x+1, y);
				g.drawString(mpbig, x, y-1);
				g.drawString(mpbig, x, y+1);
				g.setColor(mpc);
				g.drawString(mpbig, x, y);
				row1+=mpbig.length()*10;
			}
			g.setFont(UIUtils.TEXT_HURT2);
			g.setColor(Color.BLACK);
			g.drawString(mpsmall, row1-1, y);
			g.drawString(mpsmall, row1+1, y);
			g.drawString(mpsmall, row1, y-1);
			g.drawString(mpsmall, row1, y+1);
			g.setColor(mpc);
			g.drawString(mpsmall, row1, y);
		}
		return false;
	}
	
	public String getTs() {
		return ts;
	}

	public void setTs(String ts) {
		this.ts = ts;
	}

	public long getTime() {
		return time;
	}

	public void setTime(long time) {
		this.time = time;
	}
    
	
}
